package cn.lhq.controller.user;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.lhq.bean.VoteResult;
import cn.lhq.service.UserServiceImpl;

@Controller
@RequestMapping("/user")
public class ModifyPasswordController {
	@Resource
	private UserServiceImpl userServiceImpl;
	@RequestMapping("/modifyPwd.do")
	@ResponseBody
	public VoteResult execute(String username,String password){
		VoteResult result = new VoteResult();
		try {
			result = userServiceImpl.modifyPwd(username, password);
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatus(2);
			result.setMsg("修改失败");
		}
		return result;
	}
	
	@RequestMapping("/modifyPwd2.do")
	@ResponseBody
	public VoteResult execute2(String username,String oldPwd,String newPwd){
		VoteResult result = new VoteResult();
		try {
			result = userServiceImpl.modifyPwd2(username, oldPwd, newPwd);
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatus(2);
			result.setMsg("修改失败");
		}
		return result;
	}
}
